package com.yzc.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yzc.model.entity.teasing.Teasing;
import com.yzc.model.vo.teasing.TeasingVo;
import com.yzc.result.Result;
import com.yzc.service.TeasingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class TeasingController {


    @Autowired
    private TeasingService teasingService;

    @GetMapping("/loadAllMessage/{current}/{pageSize}")
    public Result loadAllMessage(@PathVariable("current") Integer pageNo,
                                 @PathVariable("pageSize") Integer pageSize) {
        Page<Teasing> pageParam = new Page<>(pageNo, pageSize);
        IPage<TeasingVo> page = teasingService.loadAllMessage(pageParam);

        return Result.success(page);
    }

    @PostMapping("/deleteTeasById")
    public Result deleteTeasById(@RequestBody Teasing id) {
       teasingService.deleteTeasById(id);
       return Result.success();
    }

}
